package com.enjoyor.soa.traffic.util.helper;

import java.util.List;

/**
 * List相关的通用工具
 *
 * @author zbr
 * @reviser zbr
 * @date 2019/3/28 13:03
 */
public class ListHelper {
    public synchronized static String listToStr(List list){
        try {
            Object[] objArr = list.toArray();
            String[] strArr = new String[objArr.length];
            for (int i = 0; i < objArr.length; i++) {
                strArr[i] = JsonHelper.beanToJsonStr(objArr[i]);
            }
            String result = String.join(",", strArr);
            return result;
        }catch(Exception e){
            String errorContext="List转String转化出错！";
            LoggerHelper.writeErrorLogInfo(errorContext,ListHelper.class.getName(),"listToStr",e);
           return null;
        }
    }
}
